<?php
namespace app\common\model;
use app\common\model\CommonModel;
use think\Db;

class Goods extends CommonModel
{
	/**
	* 添加商品信息
	*/
	public function setGoods($data)
	{
		return $this->insert($data);
	}
	/**
	* 修改商品信息
	*/
	public function updateGoods($where,$data)
	{
		return $this->where($where)->update($data);
	}
	/**
	* 获取商品信息列表
	*/
	public function getGoodsList($where,$limit = 10,$page)
	{
	   $item = $this->where($where)->paginate($limit,false,['page'=>$page]);
       return empty($item) ? array():$item->toArray();
	}
	/**
	* 获取商品列表信息
	*/
	public function goodsList($where,$field)
	{
	   $item = $this->where($where)->field($field)->select();
       return empty($item) ? array():$item->toArray();
	}
	/**
	* 删除
	*/
	public function delGoods($where)
	{
		return $this->where($where)->delete();
	}
	/**
	* 获取字段信息
	*/
	public function fieldGoods($where,$field)
	{
		return $this->where($where)->value($field);
	}
    /**
	* 获取字段列表信息
	*/
	public function fieldGoodsColumn($where,$field)
	{
		return $this->where($where)->column($field);
	}
    /**
    * 获取商品信息详情
    */
    public function goodsInfo($where)
    {
        return $this->where($where)->find();
    }
}
